//
//  SZForgetPasswordViewController.m
//  KaiJing
//
//  Created by lanou on 16/1/11.
//  Copyright © 2016年 HuangZuCui. All rights reserved.
//

#import "SZForgetPasswordViewController.h"
#import "PKRequestManager.h"

// 找回密码页面的获取验证码
#define kFindBackPassURLCode @"http://morguo.com/misc.php?mod=mobileverify&op=getpassword&getmobilesubmit=1&submitgetmobile=1&androidflag=1&appfrom=ios&iosversion=3.13"
// 提交修改密码
#define kSubmitPassURL @"http://morguo.com/member.php?mod=getpasswdapp&androidflag=1&appfrom=ios&iosversion=3.13"
@interface SZForgetPasswordViewController ()
/** 手机号码 */
@property (weak, nonatomic) IBOutlet UITextField *phoneNumber;
/** 收到的验证码 */
@property (weak, nonatomic) IBOutlet UITextField *verificationCode;
/** 新密码 */
@property (weak, nonatomic) IBOutlet UITextField *yourNewPass;
/** 确认新密码 */
@property (weak, nonatomic) IBOutlet UITextField *confirmPass;

@end

@implementation SZForgetPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addBackItem];// 添加返回Item,返回登录界面
}

/**
 *  添加返回Item
 */
- (void)addBackItem {
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(backItemAction)];
    self.navigationItem.leftBarButtonItem = backItem;
}

/**
 *  返回Item点击事件
 */
- (void)backItemAction {
    [self.navigationController popViewControllerAnimated:YES];
}

/**
 *  点击获取验证码
 */
- (IBAction)receivedVerificationCode {
#warning 先判断手机号码是否正确,是否已经注册
    
    NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
    parDic[@"formhash"] = _findPassBaseModel.formhash;
    parDic[@"mobilenumber"] = _phoneNumber.text;
    [PKRequestManager requestWithUrlString:kFindBackPassURLCode parDic:parDic method:POST finish:^(NSDictionary *dataDic) {
        SZLog(@"%@",dataDic);
    } error:^(NSError *error) {
        SZLog(@"%@",error);
    }];
}

/**
 *  提交
 */
- (IBAction)submit {
    NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
    parDic[@"formhash"] = _findPassBaseModel.formhash;
    parDic[@"getpwsubmit"] = @1;
    parDic[@"gpwdcode"] = _verificationCode.text;
    parDic[@"newpasswd1"] = _yourNewPass.text;
    parDic[@"newpasswd2"] = _confirmPass.text;
    parDic[@"phone"] = _phoneNumber.text;
    [PKRequestManager requestWithUrlString:kSubmitPassURL parDic:parDic method:POST finish:^(NSDictionary *dataDic) {
        SZLog(@"%@",dataDic);
    } error:^(NSError *error) {
        SZLog(@"%@",error);
    }];
}

@end
